package com.dgut.coal.service.impl;

import com.dgut.coal.dao.UserDao;
import com.dgut.coal.entity.User;
import com.dgut.coal.service.UserService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Yang
 * @Description:
 * @Date: Created in 23:37 2019/9/27
 * @Modifued BY:
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserDao userDao;

    @Override
    public User findUser(String username,String password){
        return userDao.findUser(username,password);

    }

    @Override
    public User findById(Integer id){

        System.out.println(userDao.findById(id));
        return userDao.findById(id);
    }
    @Override
    public List<User> findAll(int page, int size){
        PageHelper.startPage(page,size);
        return userDao.findAll();
    }

    @Override
    public List<User> findByConditions(User u) {
        return userDao.findByConditions(u);
    }

    @Override
    public void saveUser(User u) {
        userDao.saveUser(u);
    }

    @Override
    public void deleteUser(Integer id) {
        userDao.deleteUser(id);
    }

    @Override
    public void updateUser(User u) {
        userDao.updateUser(u);
    }

    @Override
    public void updatePwd(User u) {
        userDao.updatePwd(u);
    }


    @Override
    public int userCount() {
        return userDao.userCount();
    }

    @Override
    public int roleCount() {
        return userDao.roleCount();
    }
}
